package Demo;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.ArrayList;

import javax.swing.JPanel;

public class BallPanel extends JPanel{
	public ArrayList<Ball> balls = new ArrayList<Ball>(); 
	public void add(Ball b){
		balls.add(b);
	}
	public void paintComponent(Graphics g){
		super.paintComponent(g); 
		Graphics2D g2 = (Graphics2D) g;	
		
		for(Ball b : balls){
			Color c = new Color((int)(255.0*Math.random()),
					(int)(255.0*Math.random()),
					(int)(255.0*Math.random()));
			g2.setColor(Color.green);
			//g2.setColor(c);
			/*if(balls.indexOf(b) % 4 == 0){
				g2.setColor(Color.green);
			}
			else if(balls.indexOf(b) % 4 == 1)
			{
				g2.setColor(Color.orange);
			}
			else if(balls.indexOf(b) % 4 == 2)
			{
				g2.setColor(Color.red);
			}
			else{
				g2.setColor(Color.blue);
			}*/ 
			g2.fill(b.getShape());
		}
	}
}
